package com.wu.cloud.wechatcustomer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * @author xwu36
 */
@RestController
@SpringBootApplication
public class WechatCustomerApplication {

    public static void main(String[] args) {
        SpringApplication.run(WechatCustomerApplication.class, args);
    }

    @GetMapping("/api/context/user")
    @PreAuthorize("hasRole('user')")
    public Principal user(Principal user) {
        return user;
    }

    @GetMapping("/api/admin/admin")
    @PreAuthorize("hasRole('admin')")
    public Principal admin(Principal admin) {
        return admin;
    }
}
